﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using XXN.Model.Model;
using XXN.Service;

namespace XXN.Admin.Controllers
{
    public class RecommendsController : Controller
    {
        public Shopping_MallEntities db = new Shopping_MallEntities();
        public RecommendsService rs = new RecommendsService();
        public RecommendlocationsService rss = new RecommendlocationsService();
        public Shopping_MallEntities SB = new Shopping_MallEntities();

        // GET: RecommendsController
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult GetRecommends(int page, int limit)
        {
            var count = 0;
            var rsw = rs.GetRecommends(page, limit, out count);
            return Json(new { code = 0, msg = "", count = count, data = rsw }, JsonRequestBehavior.AllowGet);
        }

        [HttpPost]
        public ActionResult DelInfo(int id)
        {
            int tss = rs.DelInfo(id);
            return Content(tss.ToString());
        }

        [HttpGet]
        public ActionResult Edit(int id)
        {
            var tss = rs.GetRecommends(id);

            return View(tss);
        }

        [HttpPost]
        public ActionResult EditInfo(Recommend Ct)
        {
            var n = rs.EditInfo(Ct);
            if (n > 0)
            {
                return Json(new { success = true, msg = "成功" });
            }
            return Json(new { success = false, msg = "失败" });
        }
    }
}